var app = angular.module("app", ["xeditable"]);

app.run(function(editableOptions) {
  editableOptions.theme = 'bs3'; // bootstrap3 theme. Can be also 'bs2', 'default'
});


app.controller('EditableRowCtrl', function($scope, $filter, $http) {
	$http.get("/blank/SecurityAction/getAllSecurityList.do").success(function(data){
		console.log(data);
		$scope.securitys = data;
	});

  $scope.saveSecurity = function(data, id) {
	  	console.log(data+ " "+id);
	    //$scope.user not updated yet
	    angular.extend(data, {id: id});
	    return $http.post('/blank/SecurityAction/doSave.do', data);
  };

  $scope.removeSecurity = function(index) {
	  var id = $scope.securitys[index].ID;
	  $scope.securitys.splice(index, 1);
	  $http.get('/blank/SecurityAction/doDelete.do?deleteId='+id);
  };

  // add user
  $scope.addSecurity = function() {
    $scope.inserted = {
      ID: '',
      securityName: '',
      actionUrl: null,
      parentID: null 
    };
    $scope.securitys.push($scope.inserted);
  };
});